<script lang="ts" setup>
import type { DataFormOptionsProps } from '#/components/data-form';

import { ref } from 'vue';

import { DataForm } from '#/components/data-form';

import { useForm } from './data';

const dataFormRef = ref<InstanceType<typeof DataForm>>();
const disabled = ref(false);
const { databaseFields, rules } = useForm();

const open = (options: DataFormOptionsProps) => {
    disabled.value = !!options.data;
    dataFormRef.value?.open(options);
};

defineExpose({ open });
</script>
<template>
    <DataForm ref="dataFormRef" :fields="databaseFields" :rules="rules" api="/system/file/database" title="文件库">
        <template #maxLimit="{ form }">
            <el-input-number v-model="form.maxLimit" :min="100" :max="1000" :step="100" style="width: 100%" />
        </template>
        <template #path="{ form }">
            <el-input v-model="form.path" placeholder="请输入存储路径" :disabled="disabled" />
        </template>
    </DataForm>
</template>
